#pragma once

#include "Common/Common.h"
#include "Handlers/HandlerManager.h"

#include <QObject>
#include <QMap>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
#include <QStandardPaths>
#include <QFileDialog>
#include <QApplication>
#include <QtDebug>
#include <QDir>
#include <QFileInfo>


const QString NPK_FlAG = "NeoplePack_Bill";
const QByteArray DecodeKey = "puchikon@neople dungeon and fighter DNFDNFDNFDNFDNFDNFDNFDNF"
                          "DNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNF"
                          "DNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNF"
                          "DNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNFDNF"
                          "DNFDNFDNFDNFDNF\0";
const QString IMG_FLAG = "Neople Img File";
const QString IMAGE_FLAG = "Neople Image File";
const QString IMAGE_DIR = "ImagePacks2";
const QString SOUND_DIR = "SoundPacks";
const QString KEY_HEADER="puchikon@neople dungeon and fighter ";

class NpkCoder : public QObject
{
    Q_OBJECT
public:
    explicit NpkCoder(QObject *parent = nullptr);

    void Load(const QString &path);
    const QList<Album> &GetAlbumList();
    QImage GetSpriteImg(const Album &album, const SpriteStruct &sprite);
Q_SIGNALS:

private:
    void readNpk();
    QList<Album> readInfo();
    void readImg(Album &album);

private:
    // 原始字节数组
    QByteArray m_oriBa;
    // 正在使用的字节数组
    QDataStream *m_usingDataStreamPtr;
    QList<Album> m_albumList;
    HandlerManager *m_handlerMg;
};
